package com.shiguiwu.springboot3.kafka.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.kafka.support.ProducerListener;
import org.springframework.stereotype.Component;

/**
 * @description: 生产者监听
 * @author: stone
 * @date: Created by 2023/11/13 17:28
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springboot3.kafka.listener
 */
@Component
@Slf4j
public class MyProducerListener implements ProducerListener<String, Object> {

    @Override
    public void onSuccess(ProducerRecord<String, Object> producerRecord, RecordMetadata recordMetadata) {
        log.error("统一监听成功 ===> {}", producerRecord.topic());
    }

    @Override
    public void onError(ProducerRecord<String, Object> producerRecord, RecordMetadata recordMetadata, Exception exception) {
        log.error("统一监听失败 ===> {}", producerRecord.topic());
    }
}
